package cn.iocoder.yudao.module.member.eid.api;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.api.member.eid.MemberEidApi;
import cn.iocoder.yudao.module.api.member.eid.vo.EidVO;
import cn.iocoder.yudao.module.member.eid.dal.dataobject.MemberEidDO;
import cn.iocoder.yudao.module.member.eid.service.MemberEidService;
import cn.iocoder.yudao.module.member.eid.vo.AppEidSaveReqVO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/24
 */
@Service
@Validated
public class MemberEidApiImpl implements MemberEidApi {
    @Resource
    private MemberEidService memberEidService;

    @Override
    public EidVO getEidInfo(Long userId) {
        MemberEidDO entity = memberEidService.getIdcardByUserId(userId);
        return BeanUtils.toBean(entity, EidVO.class);
    }

    @Override
    public void updateEidInfo(Long userId, String realname, String eidNo) {
        AppEidSaveReqVO reqVO = new AppEidSaveReqVO();
        reqVO.setRealName(realname);
        reqVO.setIdcardNo(eidNo);
        memberEidService.saveIdcard(userId, reqVO);
    }

}
